home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 November
/
Chip_2004-11_cd1.bin
/
zkuste
/
dolby
/
download
/
dvdlab
/
DVDlabProRC2b.exe
/
{app}
/
Extras
/
Script
/
Gradient.talk
< prev
next >
Wrap
Text File
|
2004-03-22
|
3KB
|
108 lines
/* Simple Gradient 1.0
by Oscar, 11 Dec 2003
To run this: DROP the Script from Assets to the Object in Menu.
this example creates a simple color gradient on any object
Note: because of the bitmap merging, the text will become not-editable after you apply this
*/
// Get the current menu and selected object when you drag and drop script
// Note: if testing from Script editor make sure you have just one menu opened on desktop,
// in such case the MenuGetCurSel will return currently opened menu
menu = MenuGetCurSel()
// VTS menu 1..255, VMG menu 10001..10255
// show the current menu on top of all others
MenuActivate(menu)
object= ObjectGetCurSel(menu)
if (object==0) then
print "No object Selected"
end
endif
// get default color and type from registry
color1 = LoadInteger("GradColor1",RGB(0,0,0))
color2 = LoadInteger("GradColor2",RGB(255,0,0))
type = LoadInteger("GradType",0)
input "COLOR:From Color ", color1,"COLOR:To Color ", color2,"Direction:Vertical|Horizontal",type //"CHECK:/FILE:/COLOR:/Combo:item1|item2...
//allow cancel
if bCancelInput then
trace "Cancelled"
end
endif
// save color and grad type to registry
SaveInteger("GradColor1",color1)
SaveInteger("GradColor2",color2)
SaveInteger("GradType",type)
//get the image buffer from object and store it in buffer 1
ImgGrabObject(1,menu,object) // imgNum = temporary image buffer 1,2 or 3
imgW = ImgGetWidth(1)
imgH = ImgGetHeight(1)
// calculate the color additions per each y or x
// the color parameters are combined r,g,b, to get each component use GETR, GETB, GETC
//vertical
steps = imgH
//horizontal
if type==1 then
steps = imgW
endif
// one of the parameter in equation has to be float or else the result will be integer
// we will amake the steps float number.
cr = (GETR(color2)-GETR(color1))/FLOAT(steps)
cg = (GETG(color2)-GETG(color1))/FLOAT(steps)
cb = (GETB(color2)-GETB(color1))/FLOAT(steps)
// trace is same as print, but it will appear only in the Output window in editor
// it will never pop up window
trace "Steps =",steps, " cr =",cr," cg =",cg," cb =",cb
// this is interpreter so it is slow!
// show some progress or else people will see nothing happening for while
ProgressBar(0,steps,"Creating Gradient")
// set the initial valuse FROM color
RR = GETR(color1)
GG = GETG(color1)
BB = GETB(color1)
// loop through y or x dirrection depending on the type
if (type==0) then
for y=1 to imgH
ProgressSetPos(y)
RR=RR+cr
GG=GG+cg
BB=BB+cb
// fill whole row at once (much faster than loop through all pixels
ImgFillRow(1,y,RGB(RR,GG,BB))
next y
else
for x=1 to imgW
ProgressSetPos(x)
RR=RR+cr
GG=GG+cg
BB=BB+cb
// fill whole row at once (much faster than loop through all pixels
ImgFillCol(1,x,RGB(RR,GG,BB))
next x
endif
// now put the img buffer 1 into the object!
// all objects will be converted to bitmap objects (text will be no more editable)
ImgSetToObject(1,menu,object)